package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbItemMapper;
import com.dongdongshop.pojo.TbItem;
import com.dongdongshop.pojo.TbItemExample;
import com.dongdongshop.service.TbItemService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DubboService
public class TbItemServiceImpl implements TbItemService {
    @Resource
    private TbItemMapper tbItemMapper;

    @Override
    public List<TbItem> selectItemListByGoodsId(Long goodsId) {
        TbItemExample example = new TbItemExample();
        TbItemExample.Criteria criteria = example.createCriteria();
        criteria.andGoodsIdEqualTo(goodsId);
        criteria.andStatusEqualTo("1");
        List<TbItem> itemList = tbItemMapper.selectByExample(example);
        return itemList;
    }

    @Override
    public TbItem selectBySkuId(Long skuId) {
        return tbItemMapper.selectByPrimaryKey(skuId);
    }
}
